<template>
 <div class="combination-tree">
     <div v-if="search">
      <search-input v-model="valueData" :placeholder="placeholder"></search-input>
     </div>   
     <div class="combination-tree-node">
         
             <TreeNode :data='treeData'  @getSelect='changeSelect' @getColor="selectColor"></TreeNode>
    </div>  
 </div>
</template>

<script>
import searchInput from '@/components/common/search/searchInput.vue'
import TreeNode from './TreeNode'
export default {
name:'combination-tree',
components:{searchInput,TreeNode},
  props:{
      placeholder:{
          type:String,
          default:'搜索'
      },
        search:{
          type:Boolean,
          default:false
      },
      treeData:{
          type:Array,
          default:function() {
              return [
                {          
                        checked: true,
                        createBy: "",
                                createTime: "2018-08-10 20:40:40",
                                delFlag: 0,
                                designColor: false,
                                id: "40322777781112832",
                                isParent: true,
                                level: 0,
                                name: "湖南交水建集团",
                                open: true,
                                parentId: "0",
                                parentTitle: "一级部门",
                                sortOrder: 1,
                                status: 0,
                                title: "湖南交水建集团",
                                updateBy: "",
                                updateTime: "2020-08-14 15:19:03",
                        children:[
                            {
                                checked: true,
                                createBy:"",
                        createTime:"2020-08-14 15:07:54",
                        delFlag:0,
                        designColor:true,
                        id:"306594112193171456",
                        isParent:true,
                        level:1,
                        name:"路桥",
                        open:false,
                        parentId:"40322777781112832",
                        parentTitle:"湖南交水建集团",
                        sortOrder:0,
                        status:0,
                        title:"路桥",
                        updateBy:"",
                        updateTime:"2020-08-14 15:19:36",
                        children:[
                            {
                                checked: false,
                                createBy: "",
                                createTime: "2020-08-14 15:08:01",
                                delFlag: 0,
                                designColor: false,
                                id: "306594143910498304",
                                isParent: false,
                                level: 2,
                                name: "人力",
                                open: false,
                                parentId: "306594112193171456",
                                parentTitle: "路桥",
                                sortOrder: 0,
                                status: 0,
                                title: "人力",
                                updateBy: "",
                                updateTime: "2020-08-14 15:20:15",
                            }
                        ]
                            },
                                {
                                    checked: true,
                                    createBy: "",
                                    createTime: "2020-06-05 09:40:33",
                                    delFlag: 0,
                                    designColor: false,
                                    id: "281144584648527872",
                                    isParent: true,
                                    level: 1,
                                    length: 0,
                                    name: "湖南路桥",
                                    open: true,
                                    parentId: "40322777781112832",
                                    parentTitle: "湖南交水建集团",
                                    sortOrder: 0,
                                    status: 0,
                                    title: "湖南路桥",
                                    updateBy: "",
                                    updateTime: "2020-09-28 15:16:46",
                                    children:[
                                        {
                                        checked: true,
                                        createBy: "",
                                        createTime: "2020-08-12 10:32:48",
                                        delFlag: 0,
                                        designColor: false,
                                        id: "305800105250787328",
                                        isParent: false,
                                        level: 2,

                                        name: "财务",
                                        open: true,
                                        parentId: "281144584648527872",
                                        parentTitle: "湖南路桥",
                                        sortOrder: 0,
                                        status: 0,
                                        title: "财务",
                                        updateBy: "",
                                        updateTime: "2020-08-14 15:20:04"    ,
                                        children:[]
                                        }
                                    ]
                            }
        ]

}
        ]
       
          }
      }
  },
  data(){
    return {
        valueData:''
    }
  },
  watch:{
      valueData(val){//搜索值变化
          this.$emit("search",val);
      }
  },
  computed:{},
  methods:{
       changeSelect(val){
      this.$emit("getSelect",val)
    },
    selectColor(val){
      this.$emit("getColor",val)
    },
  },
  created(){},
  mounted(){}
}
</script>
<style lang="less" scoped>
.combination-tree{
    width: 100%;
    height: 100%;
    .combination-tree-node{
        padding-top:16px ;
    }
}
</style>
